package com.rainbow.controller;

import com.rainbow.annotation.NoLogin;
import com.rainbow.entity.User;
import com.rainbow.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author rainbow
 **/
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/register")
    @NoLogin
    public Map<String, Object> register(@RequestBody User user) {

        return userService.register(user);
    }

    @PostMapping("/login")
    @NoLogin
    public Map<String, Object> login(@RequestBody User user) {
        return userService.login(user);
    }


}
